package com.design.pattern.strategy;

/**
 * @Description 用来维护Crash对象的引用
 * @author ll
 * @createTime 2021/5/31  23:59 
 */
public class CrashContext {
	Crash crash;

	public CrashContext (String str){
		switch(str){
			case "正常收费":
				crash = new CrashNormal();
				break;
			case "打8折":
				crash = new CrashRebate("0.8");
				break;
			case "满300返100":
				crash = new CrashReturn("300","100");
				break;
			default: break;
		}
	}

	/**
	 * 提供一个方法，用改引用对象调用其对应的重写方法
	 * @param money
	 * @return
	 */
	public double getResult(double money){
		return crash.resultCrash(money);
	}
}
